define(['./config'], () => {
    //define定义一个模块

    class Tab {
        constructor() {

            this.prev = document.querySelector('.prev')
            this.next = document.querySelector('.next')
            this.slide = document.querySelector('.slide')
           

            this.init()

        }
        init() {
            this.resert()
        }
        resert() {
            pAjax({
                    url: "../data/banner.json"
                })
                .then((res) => {
                    let data = JSON.parse(res)
                    let arr = []
                    data.forEach((eee) => {
                        arr.push(eee.imageUrl)
                    })
                    let index = 0
                    this.slide.src = arr[0]
                    const psc=this.next.onclick=()=> {
                        index++
                        if (index >= arr.length) {
                            index = 0
                        }
                        this.slide.src = arr[index]
                    }
                    this.next.onclick=psc
                    setInterval(psc,3000)
                    
                    this.prev.onclick=()=> {
                        
                        index--
                        if (index < 0) {
                            index = 6
                        }
                        this.slide.src = arr[index]
                    }
                    
                })
        }
        
        

    }
    return Tab
    // })

})